vim.g.mapleader = " "

local opts = {
  performance = {
    rtp = {
      -- customize default disabled vim plugins
      disabled_plugins = {
        "2html_plugin",
        "bugreport",
        "compiler",
        "ftplugin",
        "getscript",
        "getscriptPlugin",
        "gzip",
        "logipat",
        "matchit",
        "netrw",
        "netrwFileHandlers",
        "netrwPlugin",
        "netrwSettings",
        "optwin",
        "rplugin",
        "rrhelper",
        "spellfile_plugin",
        "synmenu",
        "syntax",
        "tar",
        "tarPlugin",
        "tohtml",
        "tutor",
        "vimball",
        "vimballPlugin",
        "zip",
        "zipPlugin",
      },
    },
  },
}
require("lazy").setup("utils.vscode", opts)

-- 复制后高亮
vim.api.nvim_create_autocmd({ "TextYankPost" }, {
  pattern = { "*" },
  callback = function()
    vim.highlight.on_yank {
      timeout = 300,
    }
  end,
})

-- local opt = { noremap = true, silent = true }
-- vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv", opt)
-- vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv", opt)
vim.keymap.set({ "n", "v" }, "<leader>sc", "<cmd>call VSCodeNotify('workbench.action.showCommands')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>q", "<cmd>call VSCodeNotify('workbench.action.quit')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>lv", "<cmd>call VSCodeNotify('python.setInterpreter')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>w", "<cmd>call VSCodeNotify('workbench.action.files.save')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>n", "<cmd>call VSCodeNotify('workbench.action.files.newUntitledFile')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>fw", "<cmd>call VSCodeNotify('workbench.view.search')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>e", "<cmd>call VSCodeNotify('workbench.action.toggleSidebarVisibility')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>j", "<cmd>call VSCodeNotify('workbench.action.togglePanel')<CR>")
-- vim.keymap.set({ "n", "v" }, "<leader>js", "<cmd>call VSCodeNotify('json.sort')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>x", "<cmd>call VSCodeNotify('workbench.actions.view.problems')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>th", "<cmd>call VSCodeNotify('workbench.action.terminal.toggleTerminal')<CR>")
-- vim.keymap.set({ "n", "v" }, "<leader>e", "<cmd>call VSCodeNotify('workbench.action.toggleSidebarVisibility')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>k", "<cmd>call VSCodeNotify('workbench.action.openGlobalKeybindings')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>c", "<cmd>call VSCodeNotify('workbench.action.closeActiveEditor')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>ll", "<cmd>call VSCodeNotify('workbench.action.reloadWindow')<CR>")
vim.keymap.set(
  { "n", "v" },
  "<leader>r",
  "<cmd>call VSCodeNotify('multiCommand.cleartermina_and_python_execinterminal')<CR>"
)

vim.keymap.set({ "n", "v" }, "<leader>fp", "<cmd>call VSCodeNotify('workbench.action.openRecent')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>la", "<cmd>call VSCodeNotify('editor.action.quickFix')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>vp", "<cmd>call VSCodeNotify('editor.action.marker.next')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>gg", "<cmd>call VSCodeNotify('lazygitWrapper.open')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>ps", "<cmd>call VSCodeNotify('workbench.profiles.actions.switchProfile')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>pi", "<cmd>call VSCodeNotify('workbench.view.extensions')<CR>")

vim.keymap.set("n", "j", [[v:count ? 'j' : 'gj']], { noremap = true, expr = true })
vim.keymap.set("n", "k", [[v:count ? 'k' : 'gk']], { noremap = true, expr = true })

-- tab
vim.keymap.set({ "n", "v" }, "]b", "<cmd>call VSCodeNotify('workbench.action.navigateForward')<CR>")
vim.keymap.set({ "n", "v" }, "[b", "<cmd>call VSCodeNotify('workbench.action.navigateBack')<CR>")

-- lsp

vim.keymap.set({ "n", "v" }, "gr", "<cmd>call VSCodeNotify('editor.action.referenceSearch.trigger')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>lR", "<cmd>call VSCodeNotify('editor.action.referenceSearch.trigger')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>lr", "<cmd>call VSCodeNotify('editor.action.rename')<CR>")
vim.keymap.set({ "n", "v" }, "<leader>lh", "<cmd>call VSCodeNotify('editor.action.triggerParameterHints')<CR>")

-- require "utils.keymap"
-- require "utils.autocmds"

local opt = vim.opt
opt.ignorecase = true
opt.smartcase = true
-- -- opt.mouse:append "a"
opt.clipboard:append "unnamedplus"
opt.smartindent = true
opt.hlsearch = false
opt.helplang = "cn"
